package com.coco.controller; 
import com.coco.service.UserService;
import com.coco.entity.User; 
import com.coco.entity.User; 
import java.util.List; 
import org.springframework.beans.factory.annotation.Autowired; 
import org.springframework.web.bind.annotation.*; 


@RestController 
@RequestMapping("/user") 
public class UserController{ 


      private UserService userService; 


      @Autowired 
      public UserController(UserService userService) { 
              this.userService = userService; 
} 


      @GetMapping("/queryPage") 
      public List<User> queryPage(@RequestParam(name="pageNo", defaultValue="1") Integer pageNo, 
 @RequestParam(name="pageSize", defaultValue="50") Integer pageSize) { 
             List<User> recodes = userService.queryPage(pageNo,pageSize); 
             return recodes; 
} 


      @PostMapping("/add") 
      public void add(@RequestBody User user){ 
             userService.add(user); 
} 


      @PutMapping("/edit") 
      public void edit(@RequestBody User user){ 
             userService.edit(user); 
} 


      @DeleteMapping("/delById") 
      public void delById(@RequestParam(name="id") Integer id){ 
             userService.delById(id); 
} 
} 
